package com.cn.chaomeng.service.impl;

import com.cn.chaomeng.dao.AdminMapper;
import com.cn.chaomeng.model.Admin;
import com.cn.chaomeng.model.example.AdminExample;
import com.cn.chaomeng.service.IAdminService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author LYJ
 *         Created by Administrator on 2018/3/5 0005.
 */
@Service("adminService")
public class AdminServiceImpl implements IAdminService {

    @Resource
    private AdminMapper adminMapper;

    @Override
    public Admin selectByUsername(String username) {
        AdminExample example = new AdminExample();
        example.createCriteria().andUsernameEqualTo(username);
        List<Admin> admins = adminMapper.selectByExample(example);
        if(admins != null && admins.size() != 0){
            return admins.get(0);
        }else{
            return null;
        }
    }
}
